﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class AdminControl_UpdateEmployee : System.Web.UI.UserControl
{
    string id = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        checkId();
       
    }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
           string temp = btnInsert.Text;
        
          switch (temp)
          {
              case "Insert":
                  {
                  }
                  break;
              case "Update":
                  {
                     
                  } break;
          }
    }
    public string checkId()
    {
        string temp ="";
        id = Request.QueryString.Get("employeeid");
        if (id == "")
        {
            temp = "Insert";
        }
        else
        {
            temp = "Update";
            id = Request.QueryString.Get("employeeid");
            ShoppingDataContext spdt = new ShoppingDataContext();
            var emps = from p in spdt.STAFFs
                       where p.StaffID == id
                       select p;
            TextBox1.Text = emps.First().Fullname;
            TextBox2.Text = emps.First().position;
            TextBox3.Text = emps.First().phone;
            TextBox4.Text = emps.First().address;
            TextBox5.Text = emps.First().salary.ToString();
            TextBox6.Text = emps.First().username;
            TextBox8.Text = emps.First().birthday.ToString("dd/MMM/yyyy");
            TextBox11.Text = emps.First().joindate.ToShortDateString();
        }
        btnInsert.Text = temp;
        return temp;
    }
}
